package com.activemq.consumer;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**
 * 消息消费者
 */
@Component
public class ConsumerMessage {

    //========================== 点对点模式 ==============================
    @JmsListener(destination = "test.queue",containerFactory = "jmsListenerContainerQueue")
    public void receiveQueue(String text){
        System.out.println("消费者-接收到的消息："+text);
    }

    //========================== 发布订阅模式 ==============================
    // 这里通过传入不同的factory, 来实现发送不同类型的信息.
    @JmsListener(destination = "test.topic",containerFactory = "jmsListenerContainerTopic")
    public void receiveTopic1(String text){
        System.out.println("topic-订阅发布-消费者1-接收到的消息："+text);
    }

    @JmsListener(destination = "test.topic",containerFactory = "jmsListenerContainerTopic")
    public void receiveTopic2(String text){
        System.out.println("topic-订阅发布-消费者2-接收到的消息："+text);
    }

    @JmsListener(destination = "test.topic",containerFactory = "jmsListenerContainerTopic")
    public void receiveTopic3(String text){
        System.out.println("topic-订阅发布-消费者3-接收到的消息："+text);
    }
}
